<?php

namespace App\Service;

use App\Repositories\CourseRepository;;

use App\Transformers\Course\ShowTransformer;

class CourseService extends BaseService {
    protected $courseRepository;

    public function __construct(
        CourseRepository $courseRepository
    ){
        $this->courseRepository = $courseRepository;
    }

    /**
     * 课程列表
     * @param array $params
     * @return array
     */
    public function list(array $params){
        if (!empty($params['course_name'])){
            $query['query'] = ['course_name'=>$params['course_name']];
        }
        $query['with'] = ['level'];
        $courseObject = $this->courseRepository->list($query);
        return !empty($courseObject) ? $courseObject->toArray() : [];
    }
}
